﻿using System;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using PropertyExpression.Common;

namespace LibraryCatalog.Models
{
    public static class Util
    {
        public static string CallerName([CallerMemberName] string memberName = "")
        {
            return memberName;
        }
    }

    public static class TypeExtensions
    {
        public static string Name<T, TProperty>(
            this Type<T> it, Expression<Func<T, TProperty>> propertyExpression)
        {
            return ((MemberExpression) propertyExpression.Body).Member.Name;
        }
    }
}